<template>
  <div>
    <a-modal
      :title="title"
      :width="1000"
      :visible="visible"
      :confirmLoading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"
      cancelText="关闭"
    >
      <a-spin :spinning="confirmLoading">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper" id="queryForm">
          <a-form layout="inline">
            <a-row :gutter="24">
              <a-col :md="12" :sm="24">
                <a-form-item label="物品名称">
                  <a-input placeholder="输入物品名称查询" v-model="queryParam.itemName"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="12" :sm="24">
                <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <a-table
          ref="table"
          size="middle"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="false"
          :loading="loading"
          :rowSelection="{
            type: 'radio',
            selectedRowKeys: selectedRowKeys,
            onChange: onSelectChange
          }"
          @change="handleTableChange"
        >
        </a-table>
      </a-spin>
    </a-modal>
  </div>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, httpAction, postAction } from '@api/manage'

export default {
  name: 'OutWareHouseGoodModal',
  mixins: [JeecgListMixin],
  data() {
    return {
      //仓库数据
      receiverArr: [],
      //库存列表
      stockArr: [],
      selectGood: {},
      title: '操作',
      visible: false,
      model: {},
      layout: {
        labelCol: { span: 3 },
        wrapperCol: { span: 14 }
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      columns: [
        {
          title: '序号',
          key: 'rowIndex',
          width: 50,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '物品名称',
          align: 'left',
          dataIndex: 'itemName'
        },
        {
          title: '物品分类',
          align: 'left',
          dataIndex: 'itemCategoryName'
        },
        {
          title: '仓库编号',
          align: 'left',
          dataIndex: 'warehouseNo'
        },
        {
          title: '货架号',
          align: 'left',
          dataIndex: 'shelfNo'
        },
        {
          title: '层数',
          align: 'left',
          dataIndex: 'layerNo'
        },
        {
          title: '格子数',
          align: 'left',
          dataIndex: 'gridNo'
        }
      ],
      confirmLoading: false,
      form: this.$form.createForm(this),
      url: {
        // list: '/inWarehouseCtrl/getInWarehouseItemList'
        list: '/inWarehouseCtrl/getInWarehouseItemListWithoutLock'
        // edit: "/test/jeecgDemo/edit",
      }
    }
  },
  methods: {
    add() {
      this.edit({})
      this.loadData()
    },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.$emit('selectGood', this.selectGood)
      this.close()
      this.onClearSelected()
    },
    handleCancel() {
      this.close()
      this.onClearSelected()
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
      this.selectGood = selectionRows[0]
      console.log('行选中', selectedRowKeys, selectionRows)
      // console.log('子组件选中的物品信息', this.selectGood)
    }
  }
}
</script>

<style scoped></style>
